package haizhi.fruitmall.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class EncryptionUtil {
	public static String getEncryption(String originalStr, String saltValue,
			int encryptionTimes) {
		String hashAlgorithmName = "MD5";// md5加密
		Object credentials = originalStr;// 原字符串
		Object salt = ByteSource.Util.bytes(saltValue);// 盐值
		int hashIterations = encryptionTimes;// 加密次数
		Object encryptionStr = new SimpleHash(hashAlgorithmName, credentials,
				salt, hashIterations);// 加密后的密码
		return encryptionStr.toString();
	}
}
